package com.alibaba.citrus.cr.unified.inventory.utils;

import com.epoch.app.crunifiedinventory.consignmentorder.model.ConsignmentOrder;
import com.epoch.app.crunifiedinventory.consignmentorderline.model.ConsignmentOrderLine;
import com.epoch.app.crunifiedinventory.sdo.ConsignmentOrderLineSDO;
import com.epoch.app.crunifiedinventory.sdo.ConsignmentOrderSDO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class ConsignmentConverter {

    public static ConsignmentOrder converterOrder(ConsignmentOrderSDO consignmentOrderSDO) {
        ConsignmentOrder consignmentOrder = new ConsignmentOrder();
        BeanUtils.copyProperties(consignmentOrderSDO,consignmentOrder);
        consignmentOrder.setId(consignmentOrderSDO.getId() == null ? null : Long.parseLong(consignmentOrderSDO.getId()));
        consignmentOrder.setOuterDeliveryOrderId(consignmentOrderSDO.getOuterDeliveryOrderId());
        consignmentOrder.setOuterSalesOrderId(consignmentOrderSDO.getOuterSalesOrderId());
        consignmentOrder.setSalesOrderId(consignmentOrderSDO.getSalesOrderId());
        consignmentOrder.setOuterStoOrderId(consignmentOrderSDO.getOuterStoOrderId());
        consignmentOrder.setStoOrderId(consignmentOrderSDO.getStoOrderId());
        consignmentOrder.setSalesOrgId(consignmentOrderSDO.getSalesOrgId());
        consignmentOrder.setCreator(consignmentOrderSDO.getCreator());
        consignmentOrder.setGmt_create(consignmentOrderSDO.getCreatDate());
        consignmentOrder.setUpdater(consignmentOrderSDO.getModifier());
        consignmentOrder.setGmt_modified(consignmentOrderSDO.getModifidDate());
        consignmentOrder.setDeliveryDate(consignmentOrderSDO.getDeliveryDate());
        consignmentOrder.setFeatures(consignmentOrderSDO.getFeatures());
        consignmentOrder.setStatus(consignmentOrderSDO.getStatus());
        consignmentOrder.setSyncVersion(consignmentOrderSDO.getSyncVersion());
        consignmentOrder.setCreator(consignmentOrderSDO.getCreator());
        consignmentOrder.setUpdater(consignmentOrderSDO.getModifier());
        return consignmentOrder;
    }

    public static ConsignmentOrderLine converterOrderLine(ConsignmentOrderLineSDO consignmentOrderLineSDO) {
        ConsignmentOrderLine consignmentOrderLine = new ConsignmentOrderLine();
        BeanUtils.copyProperties(consignmentOrderLineSDO,consignmentOrderLine);
        consignmentOrderLine.setId(consignmentOrderLineSDO.getId() == null ? null : Long.parseLong(consignmentOrderLineSDO.getId()));
        consignmentOrderLine.setOuterOrderLineId(consignmentOrderLineSDO.getOuterOrderLineId());
        consignmentOrderLine.setOuterSoLineId(consignmentOrderLineSDO.getOuterSoLineId());
        consignmentOrderLine.setSoLineId(consignmentOrderLineSDO.getSoLineId());
        consignmentOrderLine.setOuterStoLineId(consignmentOrderLineSDO.getOuterStoLineId());
        consignmentOrderLine.setStoLineId(consignmentOrderLineSDO.getStoLineId());
        consignmentOrderLine.setScItemId(consignmentOrderLineSDO.getScItemId());
        consignmentOrderLine.setQty(consignmentOrderLineSDO.getQty());
        consignmentOrderLine.setPodStatus(consignmentOrderLineSDO.getPodStatus());
        consignmentOrderLine.setPodQty(consignmentOrderLineSDO.getPodQty());
        consignmentOrderLine.setFactoryCode(consignmentOrderLineSDO.getFactoryCode());
        consignmentOrderLine.setInventoryCode(consignmentOrderLineSDO.getInventoryCode());
        consignmentOrderLine.setConsignmentOrderId(consignmentOrderLineSDO.getConsignmentOrderId());
        consignmentOrderLine.setStatus(consignmentOrderLineSDO.getStatus());
        consignmentOrderLine.setSyncVersion(consignmentOrderLineSDO.getSyncVersion());
        consignmentOrderLine.setCreator(consignmentOrderLineSDO.getCreator());
        consignmentOrderLine.setUpdater(consignmentOrderLineSDO.getModifier());
        consignmentOrderLine.setSaleUnit(consignmentOrderLineSDO.getSaleUnit());
        consignmentOrderLine.setBasicQuantity(consignmentOrderLineSDO.getBasicQuantity());
        return consignmentOrderLine;
    }
}
